home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 June: Reference Library / Dev.CD Jun 94.toast / Periodicals / develop / develop Issue 10 / develop 10 code / GWorld Drawing / GWorld Routines / RectangleEffect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-08  |  1.7 KB  |  64 lines  |  [TEXT/KAHL]

  1. #include "DemoRoutines.h"
  2.  
  3. void BlastRect( long value, Rect *rect, short x, short y, GWorldPtr dst )
  4. {
  5. PixMapHandle    dstPixMap;
  6. short        dstRowBytes;
  7. long            dstBaseAddr;
  8. long            dstAddr;
  9. char            mmuMode;
  10. short        row, column;
  11. short        width;
  12. short        height;
  13.  
  14.     dstPixMap = GetGWorldPixMap ( dst );
  15.  
  16.     dstBaseAddr = (long) GetPixBaseAddr ( dstPixMap );    /* get the address of the pixmap */
  17.     dstRowBytes = (**dstPixMap).rowBytes & 0x7fff;            /* get the row increment */
  18.  
  19.     if( (x + rect->right) < (**dstPixMap).bounds.right )
  20.         width = rect->right - rect->left;
  21.     else
  22.         width = (**dstPixMap).bounds.right - (x + rect->left);
  23.  
  24.     if( (y + rect->bottom) < (**dstPixMap).bounds.bottom )
  25.         height = rect->bottom - rect->top;
  26.     else
  27.         height = (**dstPixMap).bounds.bottom - (y + rect->top);
  28.  
  29.     x -= (**dstPixMap).bounds.left;
  30.     y -= (**dstPixMap).bounds.top;
  31.  
  32.     dstBaseAddr = dstBaseAddr + (long)y*dstRowBytes + (x<<2);
  33.     mmuMode = true32b;
  34.     SwapMMUMode ( &mmuMode );                        /* set the MMU to 32-bit mode */
  35.     for ( row = 0; row < height; row++ ) 
  36.     {
  37.         dstAddr = dstBaseAddr;
  38.         for ( column = 0; column < width; column++ ) 
  39.         {    
  40.             *(long*)dstAddr = value;
  41.             dstAddr += 4;
  42.         }
  43.         dstBaseAddr = (long) ( (char *) dstBaseAddr + dstRowBytes );    /* go to the next row */
  44.     }
  45.     SwapMMUMode ( &mmuMode );                        /* restore the previous MMU mode */
  46. }
  47.  
  48. void ImageBlastRect( Rect *rect, GWorldPtr dst )
  49. {
  50. short            x,y;
  51. PixMapHandle    dstPixMap;
  52. long            value;
  53.  
  54.     dstPixMap = GetGWorldPixMap ( dst );
  55.     for( y = (**dstPixMap).bounds.top; y < (**dstPixMap).bounds.bottom; y += rect->bottom )
  56.     {
  57.         for( x = (**dstPixMap).bounds.left; x < (**dstPixMap).bounds.right; x += rect->right )
  58.         {
  59.             value = GWGet32PixelAsm( dst, x, y );
  60.             BlastRect( value, rect, x, y, dst );
  61.         }
  62.     }
  63. }
  64.